class CarFactory { 
	constructor(choose)	{
		switch(choose) {
      case 'ben':
        return new BenCar()
      case 'bao':
        return new BaoCar()
      default:
        return new Car()
    }
	}
  
  sellCar() {
    console.log(`this car: ${this.price}`)
  }
}

/**
 * 抽象类Car 模仿接口
 * 
 */
class Car {}
Car.prototype.name = 'Car Father'
Car.prototype.price = 1898

Car.prototype.createCar = (...args) => {
  console.log('this is father of car')
}

class BenCar extends Car {
  constructor() {
    super()
    this.name = 'ben car'
    this.year = 1998
  }

  createCar(...args) {
    console.log(`this is: ${this.name}`)
  }
}

class BaoCar extends Car {
  constructor(){
    super()
    this.name = 'bao car'
    this.year = 2098
  }

  createCar(...args) {
    console.log(`this is: ${this.name}`)
  }
}


const benCar = new CarFactory('ben')
console.log(benCar.name)
benCar.createCar()

const baoCar = new CarFactory('bao')
console.log(baoCar.name)
baoCar.createCar()

const car = new CarFactory()
console.log(car.name)
car.createCar()
